<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Cookies</title>
	<script>
		//setCookie
		function setCookie(name,value,iDay) {
			var oDate=new Date();
			oDate.setDate(oDate.getDate()+iDay);
			document.cookie=name+'='+value+';expires='+oDate.toUTCString();
		}
		document.cookie='name=szy';
		document.cookie='password=123456';
		alert(document.cookie);

		var oDate=new Date();
		oDate.setDate(oDate.getDate()+1);
		document.cookie='name=szy;expires='+oDate.toUTCString();

		//removeCookie
		function removeCookie(name){
			setCookie(name,1,-1)
		}
		alert(document.cookie);
		
		//getCookies
		function getCookies(name) {
			var arr=document.cookie.split('; ');
			for(var i=0;i<arr.length;i++){
				var arr2=arr[i].split('=');
				if(arr2[0]==name){
					return arr2[1];
				}
			}
			return '';
		}
		alert(getCookies('password'));
	</script>
</head>
<body>
	
</body>
</html>